import request from '../../../utils/request';
import type { AxiosPromise } from 'axios';
// 直接在文件中定义类型，避免导入问题
export interface ProjectVO {}
export interface ProjectForm {}
export interface ProjectQuery {}

/**
 * 查询开源项目列表
 * @param query 查询参数
 * @returns 项目列表
 */
export const listProject = (query?: ProjectQuery): AxiosPromise<ProjectVO[]> => {
  return request({
    url: '/nav/project/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询开源项目详细
 * @param projectId 项目ID
 * @returns 项目详情
 */
export const getProject = (projectId: string | number): AxiosPromise<ProjectVO> => {
  return request({
    url: '/nav/project/' + projectId,
    method: 'get'
  });
};

/**
 * 新增开源项目
 * @param data 项目数据
 * @returns 操作结果
 */
export const addProject = (data: ProjectForm) => {
  return request({
    url: '/nav/project',
    method: 'post',
    data: data
  });
};

/**
 * 修改开源项目
 * @param data 项目数据
 * @returns 操作结果
 */
export const updateProject = (data: ProjectForm) => {
  return request({
    url: '/nav/project',
    method: 'put',
    data: data
  });
};

/**
 * 删除开源项目
 * @param projectId 项目ID
 * @returns 操作结果
 */
export const delProject = (projectId: string | number | Array<string | number>) => {
  return request({
    url: '/nav/project/' + projectId,
    method: 'delete'
  });
};